-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backfill Blobs #13595
Backfill Blobs #13595
Conversation
6155179
to
5279dd1
Compare
func (b batch) blobRequest() *eth.BlobSidecarsByRangeRequest { | ||
return ð.BlobSidecarsByRangeRequest{ | ||
StartSlot: b.begin, | ||
Count: uint64(b.end - b.begin), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is b.end > b.begin
requirement verified somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be implicitly done in the before
method of the batcher
return len(bs.expected) - bs.next | ||
} | ||
|
||
func (bs *blobSync) validateNext(rb blocks.ROBlob) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this function need any unit test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will mostly piggy back on the tests of the verification package but I could add some additional coverage.
return len(bs.expected) - bs.next | ||
} | ||
|
||
func (bs *blobSync) validateNext(rb blocks.ROBlob) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do we verify the blob's slot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We implicitly know that they match by comparing the block roots. The base request method also adds the following validations:
@@ -27,7 +58,7 @@ type verifier struct { | |||
} | |||
|
|||
// TODO: rewrite this to use ROBlock. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this TODO comment still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it's referring to the input parameter.
beacon-chain/sync/backfill/worker.go
Outdated
backfillBlobsApproximateBytes.Add(float64(sz)) | ||
log.WithFields(b.logFields()).WithField("dlbytes", sz).Debug("backfill batch blob bytes downloaded") | ||
} | ||
if b.blobsNeeded() > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this panic if b.bs is empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not possible the way it's currently written but good idea to check it for future proofing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only way to get into this func is if state is batchBlobSync
, and I've changed the code so the only way to get into that state and set the value for batchh.results
is to also set the batch.bs
via withResults
. I think that makes calling a func that assumes batch.bs is not nil safe. This can be improved with some more refactoring after I get the clock initialization overhaul done.
beacon-chain/sync/backfill/blobs.go
Outdated
if err != nil { | ||
return nil, err | ||
} | ||
if bytesutil.ToBytes48(vb.KzgCommitment) != bytesutil.ToBytes48(c[i]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: is this better than !bytes.Equal
? I think ToBytes48 allocates memory while bytes.Equal casts to string to compare in place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can also just do [48]byte(vb.KzgCommitment) != [48]byte(c[i])
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do. i'll use bytes.Equal because I'm scared to cast to an array (ToBytes48 does padding for safety so it's not totally equivalent to casting to the underlying array).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
@@ -251,6 +243,16 @@ func New(cliCtx *cli.Context, cancel context.CancelFunc, opts ...Option) (*Beaco | |||
beacon.verifyInitWaiter = verification.NewInitializerWaiter( | |||
beacon.clockWaiter, forkchoice.NewROForkChoice(beacon.forkChoicer), beacon.stateGen) | |||
|
|||
pa := peers.NewAssigner(beacon.fetchP2P().Peers(), beacon.forkChoicer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the reason to change the ordering here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because backfill service now depends on initwaiter (ie blob validation), which depends on stategen, which depends on backfill db. stategen depends on the backfill database (to check if a given slot is available), but not on the rest of backfill. So first we init the backfill db, then stategen and blob verification, then the backfill service. This is why the backfill db coverage
package and db init is separate, to avoid circularity.
func (b batch) blobRequest() *eth.BlobSidecarsByRangeRequest { | ||
return ð.BlobSidecarsByRangeRequest{ | ||
StartSlot: b.begin, | ||
Count: uint64(b.end - b.begin), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be implicitly done in the before
method of the batcher
beacon-chain/sync/backfill/blobs.go
Outdated
if err != nil { | ||
return nil, err | ||
} | ||
if bytesutil.ToBytes48(vb.KzgCommitment) != bytesutil.ToBytes48(c[i]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can also just do [48]byte(vb.KzgCommitment) != [48]byte(c[i])
.
c346815
to
45ec5ae
Compare
Co-authored-by: Preston Van Loon <[email protected]>
Co-authored-by: Preston Van Loon <[email protected]>
Co-authored-by: Preston Van Loon <[email protected]>
45ec5ae
to
bbf2391
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
What type of PR is this?
Feature
What does this PR do? Why is it needed?
This PR adds the ability to sync blobs while backfilling blocks. This is a requirement for prysm nodes started from checkpoint sync to fulfill the promise of data availability. It's also puts us back in compliance with the p2p rpc specs which requires us to serve blocks up to
MIN_EPOCHS_FOR_BLOCK_REQUESTS
, and blobs up toMIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS
. Being unable to fulfill these responsibilities could hurt the peer score of prysm nodes and degrade network performance.Which issues(s) does this PR fix?
Fixes #13029